<?php

namespace common\models\myhtsq;

use common\models\BaseModel;

/**
 * Description of ContractReceivableModel
 * 应收款项统一model
 * @author chenxc
 */
class ContractReceivableModel extends BaseModel {

    public $receivable_id;
    public $contract_id;
    public $receivable_item_id;
    public $money_category_item_id;
    public $revenue_type;
    public $receivable_amount;
    public $receivable_date;
    public $payee_id;
    public $department_id;
    public $professional_line_id;
    public $payment_condition;
    public $billing_amount;
    public $received_amount;
    public $is_bad_debt;
    public $is_operation;
    public $remark;
    public $created_on;
    public $created_by;
    public $modified_on;
    public $modified_by;
    public $old_receivable_id;
    public $is_joint_sales;
    public $joint_saler;
    public $contract_property;

    public function __construct($config = array()) {
        parent::__construct($config);
    }

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
            // 保存合同款项信息
            [['contract_id'], 'required', 'on' => 'savecontractreceivable'],
            [['is_bad_debt', 'is_operation','is_joint_sales','contract_property'], 'integer', 'on' => 'savecontractreceivable'],
            [['receivable_amount', 'billing_amount', 'received_amount'], 'number', 'on' => 'savecontractreceivable'],
            [['receivable_date', 'created_on', 'modified_on'], 'safe', 'on' => 'savecontractreceivable'],
            [['payment_condition', 'remark'], 'string', 'on' => 'savecontractreceivable'],
            [['revenue_type','receivable_id', 'contract_id', 'receivable_item_id', 'money_category_item_id', 'payee_id', 'department_id', 'professional_line_id', 'created_by', 'modified_by','joint_saler'], 'string', 'max' => 36, 'on' => 'savecontractreceivable'],
            [['billing_amount', 'received_amount', 'is_bad_debt', 'is_operation'], 'default', 'value' => 0, 'on' => 'savecontractreceivable'],
            // 保存合同款项拆分信息
            [['contract_id', 'old_receivable_id'], 'required', 'on' => 'splitontractreceivable'],
            [['is_bad_debt', 'is_operation'], 'integer', 'on' => 'splitontractreceivable'],
            [['receivable_amount', 'billing_amount', 'received_amount'], 'number', 'on' => 'splitontractreceivable'],
            [['receivable_date', 'created_on', 'modified_on'], 'safe', 'on' => 'splitontractreceivable'],
            [['payment_condition', 'remark'], 'string', 'on' => 'splitontractreceivable'],
            [['revenue_type','receivable_id', 'contract_id', 'receivable_item_id', 'money_category_item_id', 'payee_id', 'department_id', 'professional_line_id', 'created_by', 'modified_by', 'old_receivable_id'], 'string', 'max' => 36, 'on' => 'splitontractreceivable'],
            [['billing_amount', 'received_amount', 'is_bad_debt', 'is_operation'], 'default', 'value' => 0, 'on' => 'splitontractreceivable'],
            // 变更责任人
            [['contract_id'], 'required', 'on' => 'changeresponsibleperson'],
            [['is_bad_debt', 'is_operation'], 'integer', 'on' => 'changeresponsibleperson'],
            [['receivable_amount', 'billing_amount', 'received_amount'], 'number', 'on' => 'changeresponsibleperson'],
            [['receivable_date', 'created_on', 'modified_on'], 'safe', 'on' => 'changeresponsibleperson'],
            [['payment_condition', 'remark'], 'string', 'on' => 'changeresponsibleperson'],
            [['revenue_type', 'receivable_id', 'contract_id', 'receivable_item_id', 'money_category_item_id', 'payee_id', 'department_id', 'professional_line_id', 'created_by', 'modified_by'], 'string', 'max' => 36, 'on' => 'changeresponsibleperson'],
            [['billing_amount', 'received_amount', 'is_bad_debt', 'is_operation'], 'default', 'value' => 0, 'on' => 'changeresponsibleperson'],
            // 变更应收时间            
            [['contract_id'], 'required', 'on' => 'changereceivabledate'],
            [['is_bad_debt', 'is_operation'], 'integer', 'on' => 'changereceivabledate'],
            [['receivable_amount', 'billing_amount', 'received_amount'], 'number', 'on' => 'changereceivabledate'],
            [['receivable_date', 'created_on', 'modified_on'], 'safe', 'on' => 'changereceivabledate'],
            [['payment_condition', 'remark'], 'string', 'on' => 'changereceivabledate'],
            [['revenue_type', 'receivable_id', 'contract_id', 'receivable_item_id', 'money_category_item_id', 'payee_id', 'department_id', 'professional_line_id', 'created_by', 'modified_by'], 'string', 'max' => 36, 'on' => 'changereceivabledate'],
            [['billing_amount', 'received_amount', 'is_bad_debt', 'is_operation'], 'default', 'value' => 0, 'on' => 'changereceivabledate']
        ];
    }

}
